///  use National Bureau of Statistics's data, build tree, the [point] is trees's node
class AddressPoint {
  String code;
  String parentCode;
  List<AddressPoint> child = [];
  int depth;
  String letter;
  String name;

  static AddressPoint get nullPoint => AddressPoint(
      code: null, parentCode: null, child: [], letter: null, name: null);

  bool get isNull => this.code == null;

  AddressPoint(
      {this.code,
      this.parentCode,
      child,
      this.depth,
      this.letter = '',
      this.name = ''}) {
    this.child = child ?? [];
  }

  /// add node for Point, the node's type must is [AddressPoint]
  addChild(AddressPoint node) {
    this.child.add(node);
  }

  @override
  String toString() {
    return "{code: $code,  parentCode: $parentCode,  name: $name, letter: $letter, child: Array & length = ${child == null ? 0 : child.length}";
  }
}
